﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Steamrunner
{
    class Player : DrawableGameComponent
    {
        #region Variables
        
        string playerId;
        int playerColor;

        SpriteSheetManager spritesheetManager = null;
        SpriteBatch spriteBatch = null;
        InputManager inputManager = null;
        PhysicsManager physicsManager = null;
        LevelManager levelManager = null;
        MusicManager musicManager = null;
        static EffectManager effectManager = null;

        Vector2 position = Vector2.Zero;
        float rotation = 0.0f;
        Color color = Color.White;

        Vector2 speed = Vector2.Zero;

        int currentState = (int)Enums.State.NOTSTARTED;
        string currentEffect = "";

        bool justFinished = false;
        bool continueSliding = false;
        
        #endregion

        #region Properties
        public string PlayerId
        {
            get { return playerId; }
        }

        public int PlayerColorInt
        {
            get { return playerColor; }
        }

        public SpriteSheetManager SpritesheetManager
        {
            get { return spritesheetManager; }
            set { spritesheetManager = value; }
        }

        public SpriteBatch SpriteBatch
        {
            get { return spriteBatch; }
        }

        public InputManager InputManager
        {
            get { return inputManager; }
        }

        public PhysicsManager PhysicsManager
        {
            get { return physicsManager; }
        }

        public MusicManager MusicManager
        {
            get { return musicManager; }
        }

        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        public float Rotation
        {
            get { return rotation; }
            set { rotation = value; }
        }

        public Color Color
        {
            get { return color; }
            set { color = value; }
        }

        public Vector2 Speed
        {
            get { return speed; }
            set { speed = value; }
        }

        public int CurrentState
        {
            get { return currentState; }
            set { currentState = value; }
        }

        public bool JustFinished
        {
            get { return justFinished; }
            set { justFinished = value; }
        }
        #endregion

        public Player(Game game, SpriteBatch spriteBatch, InputManager inputManager, int playerColor, SpriteSheetManager spritesheetManager, LevelManager levelManager, MusicManager musicManager)
            : base(game)
        {
            this.spriteBatch = spriteBatch;
            this.inputManager = inputManager;
            this.playerColor = playerColor;
            this.spritesheetManager = spritesheetManager;
            this.levelManager = levelManager;
            this.musicManager = musicManager;
        }

        public override void Initialize()
        {
            if (effectManager == null)
            {
                effectManager = new EffectManager(Game, spriteBatch, spritesheetManager);
                effectManager.Initialize();
            }

            switch (playerColor)
            {
                case (int)Enums.PlayerColor.YELLOW:
                    playerId = "yellow";
                    break;
                case (int)Enums.PlayerColor.GREEN:
                    playerId = "green";
                    break;
                case (int)Enums.PlayerColor.BLUE:
                    playerId = "blue";
                    break;
                case (int)Enums.PlayerColor.RED:
                    playerId = "red";
                    break;
            }

            string filepath = "Images//Players//";
            string filename = playerId + "_walking";
            SpriteSheet spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(6, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_standing";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(3, 1), 1000, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_jogging";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(6, 1), 80, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_running";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(6, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_sprinting";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(1, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_jumping";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(6, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_leftjumping";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(6, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_falling";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(6, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_leftfalling";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(6, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_sliding";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(64f, 32f), new Point(96, 64), Point.Zero, new Point(6, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_wallhugging";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(1, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);
            filename = playerId + "_leftwallhugging";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(1, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_falldamage";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(1, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            filename = playerId + "_bumpwall";
            spritesheet = new SpriteSheet(Game, filepath + filename, new Vector2(32f, 32f), new Point(64, 64), Point.Zero, new Point(1, 1), 40, spriteBatch);
            spritesheet.Initialize();
            spritesheetManager.AddSpriteSheet(filename, spritesheet);

            physicsManager = new PhysicsManager(Game, this, levelManager);
            physicsManager.Initialize();

            position = new Vector2(170f, 1408f);

            base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            HandleInput();

            physicsManager.Update(gameTime);

            // Updating the correct animation
            switch (currentState)
            {
                case (int)Enums.State.NOTSTARTED:
                    spritesheetManager.UpdateSpriteSheet(playerId + "_standing", gameTime);
                    if (currentEffect != "")
                    {
                        effectManager.FlushEffect(currentEffect);
                        currentEffect = "";
                    }
                    break;
                case (int)Enums.State.WALKING:
                    spritesheetManager.UpdateSpriteSheet(playerId + "_walking", gameTime);
                    if (currentEffect != "")
                    {
                        effectManager.FlushEffect(currentEffect);
                        currentEffect = "";
                    }
                    break;
                case (int)Enums.State.JOGGING:
                    spritesheetManager.UpdateSpriteSheet(playerId + "_jogging", gameTime);
                    if (currentEffect != "")
                    {
                        effectManager.FlushEffect(currentEffect);
                        currentEffect = "";
                    }
                    break;
                case (int)Enums.State.RUNNING:
                    spritesheetManager.UpdateSpriteSheet(playerId + "_running", gameTime);
                    if (currentEffect != "RunningEffect")
                    {
                        if (currentEffect != "")
                        {
                            effectManager.FlushEffect(currentEffect);
                        }

                        if (physicsManager.CurrentTileLevel / 3 == 2)
                        {
                            currentEffect = "RunningEffectCopper";
                        }
                        else if (physicsManager.CurrentTileLevel / 3 == 1)
                        {
                            currentEffect = "RunningEffect";
                        }
                        else
                        {
                            currentEffect = "";
                        }
                    }
                    break;
                case (int)Enums.State.SPRINTING:
                    spritesheetManager.UpdateSpriteSheet(playerId + "_sprinting", gameTime);
                    if (currentEffect != "")
                    {
                        effectManager.FlushEffect(currentEffect);
                        currentEffect = "";
                    }
                    break;
                case (int)Enums.State.JUMPING:
                    if (currentEffect != "JumpEffect" || currentEffect != "LeftJumpEffect")
                    {
                        if (currentEffect != "")
                        {
                            effectManager.FlushEffect(currentEffect);
                        }

                        if (physicsManager.OnTheRight)
                        {
                            currentEffect = "JumpEffect";
                        }
                        else
                        {
                            currentEffect = "LeftJumpEffect";
                        }
                    }
                    if (physicsManager.OnTheRight)
                    {
                        spritesheetManager.UpdateSpriteSheet(playerId + "_jumping", gameTime);
                    }
                    else
                    {
                        spritesheetManager.UpdateSpriteSheet(playerId + "_leftjumping", gameTime);
                    }
                    break;
                case (int)Enums.State.FALLING:
                    if (currentEffect != "FallingEffect" || currentEffect != "LeftFallingEffect")
                    {
                        if (currentEffect != "")
                        {
                            effectManager.FlushEffect(currentEffect);
                        }

                        if (physicsManager.OnTheRight)
                        {
                            currentEffect = "FallingEffect";
                        }
                        else
                        {
                            currentEffect = "LeftFallingEffect";
                        }
                    }
                    if (physicsManager.OnTheRight)
                    {
                        spritesheetManager.UpdateSpriteSheet(playerId + "_falling", gameTime);
                    }
                    else
                    {
                        spritesheetManager.UpdateSpriteSheet(playerId + "_leftfalling", gameTime);
                    }
                    break;
                case (int)Enums.State.SLIDING:
                    spritesheetManager.UpdateSpriteSheet(playerId + "_sliding", gameTime);
                    if (currentEffect != "SlideEffect")
                    {
                        if (currentEffect != "")
                        {
                            effectManager.FlushEffect(currentEffect);
                        }
                        currentEffect = "SlideEffect";
                    }
                    if (continueSliding)
                    {
                        if (physicsManager.EndSliding())
                        {
                            continueSliding = false;
                            currentState = physicsManager.StateAtStateChange;
                        }
                    }
                    break;
                case (int)Enums.State.WALLJUMPING:
                    if (currentEffect != "WallHuggingEffect" || currentEffect != "LeftWallHuggingEffect")
                    {
                        if (currentEffect != "")
                        {
                            effectManager.FlushEffect(currentEffect);
                        }

                        if (physicsManager.OnTheRight)
                        {
                            currentEffect = "WallHuggingEffect";
                        }
                        else
                        {
                            currentEffect = "LeftWallHuggingEffect";
                        }
                    }
                    if (physicsManager.OnTheRight)
                    {
                        spritesheetManager.UpdateSpriteSheet(playerId + "_wallhugging", gameTime);
                    }
                    else
                    {
                        spritesheetManager.UpdateSpriteSheet(playerId + "_leftwallhugging", gameTime);
                    }
                    break;
                case (int)Enums.State.FALLDAMAGE:
                    spritesheetManager.UpdateSpriteSheet(playerId + "_falldamage", gameTime);
                    if (currentEffect != "FallDamageEffect")
                    {
                        if (currentEffect != "")
                        {
                            effectManager.FlushEffect(currentEffect);
                        }
                        currentEffect = "FallDamageEffect";
                    }
                    break;
                case (int)Enums.State.WALLBUMP:
                    spritesheetManager.UpdateSpriteSheet(playerId + "_bumpwall", gameTime);
                    if (currentEffect != "")
                    {
                        effectManager.FlushEffect(currentEffect);
                        currentEffect = "";
                    }
                    break;
                case (int)Enums.State.FINISHED:
                    currentEffect = "";
                    break;
            }

            if (currentEffect != "")
            {
                effectManager.UpdateEffect(currentEffect, gameTime);
            }

            base.Update(gameTime);
        }

        private void HandleInput()
        {
            switch (playerColor)
            {
                case (int)Enums.PlayerColor.BLUE:
                    if (inputManager.JustPressed(Keys.S))
                    {
                        if (currentState >= (int)Enums.State.WALKING && currentState <= (int)Enums.State.SPRINTING || physicsManager.OkToJump)
                        {
                            physicsManager.StateAtStateChange = currentState;

                            musicManager.PlayRocket("Rocket");

                            currentState = (short)Enums.State.SLIDING;
                        }
                    }

                    if (currentState == (int)Enums.State.SLIDING)
                    {
                        if (inputManager.JustReleased(Keys.S))
                        {
                            if (physicsManager.EndSliding())
                            {
                                currentState = physicsManager.StateAtStateChange;
                            }
                            else
                            {
                                continueSliding = true;
                            }
                        }
                    }

                    if (physicsManager.StateAtStateChange == (int)Enums.State.SLIDING && inputManager.JustReleased(Keys.S))
                    {
                        musicManager.StopRocket();
                        if (speed.X > physicsManager.JoggingMaxSpeed)
                        {
                            physicsManager.StateAtStateChange = (int)Enums.State.RUNNING;
                        }
                        else
                        {
                            physicsManager.StateAtStateChange = (int)Enums.State.JOGGING;
                        }
                    }

                    if (inputManager.JustPressed(Keys.W))
                    {
                        if (currentState >= (int)Enums.State.WALKING && currentState <= (int)Enums.State.SPRINTING || currentState == (int)Enums.State.SLIDING || physicsManager.OkToJump)
                        {
                            if (physicsManager.OkToJump || currentState == (int)Enums.State.WALLBUMP)
                            {
                                physicsManager.StateAtStateChange = (int)Enums.State.JOGGING;
                            }
                            else if (currentState != (int)Enums.State.SLIDING)
                            {
                                physicsManager.StateAtStateChange = currentState;
                            }

                            currentState = (int)Enums.State.JUMPING;

                            physicsManager.StateJustChanged = true;
                        }
                    }

                    if (currentState == (int)Enums.State.WALLJUMPING)
                    {
                        if (physicsManager.OnTheRight)
                        {
                            if (inputManager.JustPressed(Keys.A))
                            {
                                physicsManager.WallJumpToTheLeft = true;
                            }
                        }
                        else
                        {
                            if (inputManager.JustPressed(Keys.D))
                            {
                                physicsManager.WallJumpToTheRight = true;
                            }
                        }
                    }
                    break;

                case (int)Enums.PlayerColor.GREEN:
                    if (inputManager.JustPressed(Keys.Down))
                    {
                        if (currentState >= (int)Enums.State.WALKING && currentState <= (int)Enums.State.SPRINTING || physicsManager.OkToJump)
                        {
                            physicsManager.StateAtStateChange = currentState;

                            musicManager.PlayRocket("Rocket");

                            currentState = (short)Enums.State.SLIDING;
                        }
                    }

                    if (currentState == (int)Enums.State.SLIDING)
                    {
                        if (inputManager.JustReleased(Keys.Down))
                        {
                            if (physicsManager.EndSliding())
                            {
                                currentState = physicsManager.StateAtStateChange;
                            }
                            else
                            {
                                continueSliding = true;
                            }
                        }
                    }

                    if (physicsManager.StateAtStateChange == (int)Enums.State.SLIDING && inputManager.JustReleased(Keys.Down))
                    {
                        musicManager.StopRocket();
                        if (speed.X > physicsManager.JoggingMaxSpeed)
                        {
                            physicsManager.StateAtStateChange = (int)Enums.State.RUNNING;
                        }
                        else
                        {
                            physicsManager.StateAtStateChange = (int)Enums.State.JOGGING;
                        }
                    }

                    if (inputManager.JustPressed(Keys.Up))
                    {
                        if (currentState >= (int)Enums.State.WALKING && currentState <= (int)Enums.State.SPRINTING || currentState == (int)Enums.State.SLIDING || physicsManager.OkToJump)
                        {
                            if (physicsManager.OkToJump || currentState == (int)Enums.State.WALLBUMP)
                            {
                                physicsManager.StateAtStateChange = (int)Enums.State.JOGGING;
                            }
                            else if (currentState != (int)Enums.State.SLIDING)
                            {
                                physicsManager.StateAtStateChange = currentState;
                            }

                            currentState = (int)Enums.State.JUMPING;

                            physicsManager.StateJustChanged = true;
                        }
                    }

                    if (currentState == (int)Enums.State.WALLJUMPING)
                    {
                        if (physicsManager.OnTheRight)
                        {
                            if (inputManager.JustPressed(Keys.Left))
                            {
                                physicsManager.WallJumpToTheLeft = true;
                            }
                        }
                        else
                        {
                            if (inputManager.JustPressed(Keys.Right))
                            {
                                physicsManager.WallJumpToTheRight = true;
                            }
                        }
                    }
                    break;

                case (int)Enums.PlayerColor.RED:
                    if (inputManager.JustPressed(Keys.J))
                    {
                        if (currentState >= (int)Enums.State.WALKING && currentState <= (int)Enums.State.SPRINTING || physicsManager.OkToJump)
                        {
                            physicsManager.StateAtStateChange = currentState;

                            musicManager.PlayRocket("Rocket");

                            currentState = (short)Enums.State.SLIDING;
                        }
                    }

                    if (currentState == (int)Enums.State.SLIDING)
                    {
                        if (inputManager.JustReleased(Keys.J))
                        {
                            if (physicsManager.EndSliding())
                            {
                                currentState = physicsManager.StateAtStateChange;
                            }
                            else
                            {
                                continueSliding = true;
                            }
                        }
                    }

                    if (physicsManager.StateAtStateChange == (int)Enums.State.SLIDING && inputManager.JustReleased(Keys.J))
                    {
                        musicManager.StopRocket();
                        if (speed.X > physicsManager.JoggingMaxSpeed)
                        {
                            physicsManager.StateAtStateChange = (int)Enums.State.RUNNING;
                        }
                        else
                        {
                            physicsManager.StateAtStateChange = (int)Enums.State.JOGGING;
                        }
                    }

                    if (inputManager.JustPressed(Keys.U))
                    {
                        if (currentState >= (int)Enums.State.WALKING && currentState <= (int)Enums.State.SPRINTING || currentState == (int)Enums.State.SLIDING || physicsManager.OkToJump)
                        {
                            if (physicsManager.OkToJump || currentState == (int)Enums.State.WALLBUMP)
                            {
                                physicsManager.StateAtStateChange = (int)Enums.State.JOGGING;
                            }
                            else if (currentState != (int)Enums.State.SLIDING)
                            {
                                physicsManager.StateAtStateChange = currentState;
                            }

                            currentState = (int)Enums.State.JUMPING;

                            physicsManager.StateJustChanged = true;
                        }
                    }

                    if (currentState == (int)Enums.State.WALLJUMPING)
                    {
                        if (physicsManager.OnTheRight)
                        {
                            if (inputManager.JustPressed(Keys.H))
                            {
                                physicsManager.WallJumpToTheLeft = true;
                            }
                        }
                        else
                        {
                            if (inputManager.JustPressed(Keys.K))
                            {
                                physicsManager.WallJumpToTheRight = true;
                            }
                        }
                    }
                    break;

                case (int)Enums.PlayerColor.YELLOW:
                    if (inputManager.JustPressed(Keys.NumPad2))
                    {
                        if (currentState >= (int)Enums.State.WALKING && currentState <= (int)Enums.State.SPRINTING || physicsManager.OkToJump)
                        {
                            physicsManager.StateAtStateChange = currentState;

                            musicManager.PlayRocket("Rocket");

                            currentState = (short)Enums.State.SLIDING;
                        }
                    }

                    if (currentState == (int)Enums.State.SLIDING)
                    {
                        if (inputManager.JustReleased(Keys.NumPad2))
                        {
                            if (physicsManager.EndSliding())
                            {
                                currentState = physicsManager.StateAtStateChange;
                            }
                            else
                            {
                                continueSliding = true;
                            }
                        }
                    }

                    if (physicsManager.StateAtStateChange == (int)Enums.State.SLIDING && inputManager.JustReleased(Keys.NumPad2))
                    {
                        musicManager.StopRocket();
                        if (speed.X > physicsManager.JoggingMaxSpeed)
                        {
                            physicsManager.StateAtStateChange = (int)Enums.State.RUNNING;
                        }
                        else
                        {
                            physicsManager.StateAtStateChange = (int)Enums.State.JOGGING;
                        }
                    }

                    if (inputManager.JustPressed(Keys.NumPad5))
                    {
                        if (currentState >= (int)Enums.State.WALKING && currentState <= (int)Enums.State.SPRINTING || currentState == (int)Enums.State.SLIDING || physicsManager.OkToJump)
                        {
                            if (physicsManager.OkToJump || currentState == (int)Enums.State.WALLBUMP)
                            {
                                physicsManager.StateAtStateChange = (int)Enums.State.JOGGING;
                            }
                            else if (currentState != (int)Enums.State.SLIDING)
                            {
                                physicsManager.StateAtStateChange = currentState;
                            }

                            currentState = (int)Enums.State.JUMPING;

                            physicsManager.StateJustChanged = true;
                        }
                    }

                    if (currentState == (int)Enums.State.WALLJUMPING)
                    {
                        if (physicsManager.OnTheRight)
                        {
                            if (inputManager.JustPressed(Keys.NumPad1))
                            {
                                physicsManager.WallJumpToTheLeft = true;
                            }
                        }
                        else
                        {
                            if (inputManager.JustPressed(Keys.NumPad3))
                            {
                                physicsManager.WallJumpToTheRight = true;
                            }
                        }
                    }
                    break;
            }
        }

        public override void Draw(GameTime gameTime)
        {
            if (currentEffect == "JumpEffect" || currentEffect == "LeftJumpEffect")
            {
                effectManager.DrawEffect(currentEffect, gameTime, position);
            }

            switch (currentState)
            {
                case (int)Enums.State.NOTSTARTED:
                    spritesheetManager.DrawSpriteSheet(playerId + "_standing", gameTime, position, rotation);
                    break;
                case (int)Enums.State.WALKING:
                    spritesheetManager.DrawSpriteSheet(playerId + "_walking", gameTime, position, rotation);
                    break;
                case (int)Enums.State.JOGGING:
                    spritesheetManager.DrawSpriteSheet(playerId + "_jogging", gameTime, position, rotation);
                    break;
                case (int)Enums.State.RUNNING:
                    spritesheetManager.DrawSpriteSheet(playerId + "_running", gameTime, position, rotation);
                    break;
                case (int)Enums.State.SPRINTING:
                    spritesheetManager.DrawSpriteSheet(playerId + "_sprinting", gameTime, position, rotation);
                    break;
                case (int)Enums.State.JUMPING:
                    if (physicsManager.OnTheRight)
                    {
                        spritesheetManager.DrawSpriteSheet(playerId + "_jumping", gameTime, position, rotation);
                    }
                    else
                    {
                        spritesheetManager.DrawSpriteSheet(playerId + "_leftjumping", gameTime, position, rotation);
                    }
                    break;
                case (int)Enums.State.FALLING:
                    if (physicsManager.OnTheRight)
                    {
                        spritesheetManager.DrawSpriteSheet(playerId + "_falling", gameTime, position, rotation);
                    }
                    else
                    {
                        spritesheetManager.DrawSpriteSheet(playerId + "_leftfalling", gameTime, position, rotation);
                    }
                    break;
                case (int)Enums.State.SLIDING:
                    spritesheetManager.DrawSpriteSheet(playerId + "_sliding", gameTime, position, rotation);
                    break;
                case (int)Enums.State.WALLJUMPING:
                    if (physicsManager.OnTheRight)
                    {
                        spritesheetManager.DrawSpriteSheet(playerId + "_wallhugging", gameTime, position, rotation);
                    }
                    else
                    {
                        spritesheetManager.DrawSpriteSheet(playerId + "_leftwallhugging", gameTime, position, rotation);
                    }
                    break;
                case (int)Enums.State.FALLDAMAGE:
                    spritesheetManager.DrawSpriteSheet(playerId + "_falldamage", gameTime, position, rotation);
                    break;
                case (int)Enums.State.WALLBUMP:
                    spritesheetManager.DrawSpriteSheet(playerId + "_bumpwall", gameTime, position, rotation);
                    break;
                case (int)Enums.State.FINISHED:
                    // ??
                    break;
            }

            if (currentEffect != "JumpEffect" && currentEffect != "LeftJumpEffect" && currentEffect != "")
            {
                effectManager.DrawEffect(currentEffect, gameTime, position);
            }

            base.Draw(gameTime);
        }
    }
}
